home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17877 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.0 KB  |  55 lines

  1. Path: news.unt.edu!cc0003
  2. From: cc0003@jove.acs.unt.edu (Chen-five Chi)
  3. Newsgroups: comp.lang.c++
  4. Subject: Question about abstract base class
  5. Date: 17 Apr 1996 23:15:08 GMT
  6. Organization: University of North Texas
  7. Message-ID: <4l3u1s$j80@hermes.acs.unt.edu>
  8. NNTP-Posting-Host: jove.acs.unt.edu
  9. X-Newsreader: TIN [version 1.2 PL2]
  10.  
  11. I just wrote a simple program like this:
  12.  
  13. class shape
  14.  
  15. {
  16.    public:
  17.     virtual void print() const = 0;
  18. ........
  19. }
  20. clase TwoDimensionObject: public shape
  21. {
  22.    public:
  23.     virtual void area() const = 0;
  24. ...
  25. }
  26. class Square: public TwoDimensionObject
  27. {
  28.    private:
  29.     int side;
  30.    public:
  31.     virtual void area()
  32.     {
  33.        cout << "Square area: " << (side * side);
  34.     }
  35. }
  36. ...
  37. void main()
  38. {
  39.     Square s1;
  40. ....
  41. }
  42.  
  43. ==============================
  44. And I get a compiler error in BC 4.51 said "s1 is abstract base class...."
  45. After I move the keyword "const", the program runs normally without any 
  46. problem. 
  47.  
  48. I would like to know
  49. "Why I Could not put 'const' in the ABC? and the different these two?
  50.  
  51. Your kindness help is appreciated.
  52.  
  53. Steven
  54.  
  55.